package com.touchportfolio.controller
{
	import com.touchportfolio.model.ApplicationModel;
	
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;

	public class KeyboardController
	{
		private var _appModel:ApplicationModel;
		
		public function KeyboardController()
		{
			_appModel = ApplicationModel.getInstance();
			_appModel.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
		}
		
		private function onKeyDown(e:KeyboardEvent):void
		{
			switch(e.keyCode) {
				case Keyboard.UP:
					_appModel.activeRow--;
					break;
				
				case Keyboard.DOWN:
					_appModel.activeRow++;
					break;
				
				case Keyboard.RIGHT:
					_appModel.activeRowOpen = true;
					break;
				
				case Keyboard.LEFT:
					_appModel.activeRowOpen = false;
					break;
			}
		}
	}
}